package com.xsprite.managesys.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xsprite.managesys.service.ServerConfig;
import com.xsprite.managesys.service.ServersManager;

import net.sf.json.JSONArray;

/**
 * Servlet implementation class GetServersServlet
 */
public class GetServersServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		super.service(req, resp);
		List<ServerConfig> serverConfigs = ServersManager.getInstance().getServerConfigs();
		JSONArray jsonArray = JSONArray.fromObject(serverConfigs);
		PrintWriter out = resp.getWriter();  
        out.write(jsonArray.toString());
	}
}
